#!/bin/bash
TIME_TAG=`date "+%Y%m%d%H%m"`
IMAGE_RESP=192.168.0.225:8060/$1/
GIT_VERSION=`git log -1 --pretty=format:"%h"`

MODULES=$2

cd $2/$3

echo "Dockerfile 所在的路径是: " && pwd

IMAGE_NAME=${IMAGE_RESP}$MODULE_NAME:${TIME_TAG}_${GIT_VERSION}

echo "开始构建镜像: ${IMAGE_NAME}"

docker build -t ${IMAGE_NAME} .

echo "开始推送镜像：${IMAGE_NAME}至私有仓库：${IMAGE_RESP}"
docker push ${IMAGE_NAME}

echo "删除当前镜像： ${IMAGE_NAME}"
docker rmi ${IMAGE_NAME}

echo "将镜像写入临时文件"
echo "${IMAGE_NAME}" > $4/image_$MODULE_NAME

echo "build $MODULE_NAME end!"